#!/bin/bash
#
# live: Late init script for live image
#
# chkconfig: 345 99 01
# description: Late init script for live image.

. /etc/init.d/functions

if ! strstr "`cat /proc/cmdline`" liveimg || [ "$1" != "start" ] || [ -e /.liveimg-late-configured ] ; then
    exit 0
fi

exists() {
    which $1 >/dev/null 2>&1 || return
    $*
}

touch /.liveimg-late-configured

# read some variables out of /proc/cmdline
for o in `cat /proc/cmdline` ; do
    case $o in
    ks=*)
        ks="${o#ks=}"
        ;;
    xdriver=*)
        xdriver="--set-driver=${o#xdriver=}"
        ;;
    esac
done

# if liveinst or textinst is given, start anaconda
if strstr "`cat /proc/cmdline`" liveinst ; then
   plymouth --quit
   /usr/sbin/liveinst $ks
fi
if strstr "`cat /proc/cmdline`" textinst ; then
   plymouth --quit
   /usr/sbin/liveinst --text $ks
fi

# configure X, allowing user to override xdriver
if [ -n "" ]; then
    exists system-config-display --noui --reconfig --set-depth=24 $xdriver
fi

